package com.myres.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.myres.model.User;

public class UserDao extends HibernateDaoSupport {
	public User get(int id){
		return getHibernateTemplate().get(User.class, id);
	}
	
	public User load(int id){
		return getHibernateTemplate().load(User.class, id);
	}
	
	@SuppressWarnings("unchecked")
	public List<User> findByName(String name){
		String hql="from User u where u.name="+"'"+name+"'";
		return (List<User>)getHibernateTemplate().find(hql);
	}
	
	public void delete(User user){
		getHibernateTemplate().delete(user);
	}
	
	public int update(User user){
		getHibernateTemplate().update(user);
		return user.getId();
	}
	
	public int save(User user){
		getHibernateTemplate().save(user);
		return user.getId();
	}
	
}
